home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / extras / Direct3D / Tools / Maya25 / MyDt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  4.9 KB  |  400 lines

  1. #ifndef MyDt_h
  2. #define MyDt_h
  3.  
  4. // Dt API
  5. #include <MDt.h>
  6. #include <MDtExt.h>
  7.  
  8.  
  9. struct Rep {
  10.     int        m_iTexCoordIdx;        // index into lump of texture coordinates 
  11.     int        m_iNormalIdx;        // index into lump of normals
  12.  
  13.     int        m_iNext;            // next repetition
  14.     int        m_iFirst;            // can also be thought of as "index into lump of vertices";
  15.  
  16.     // IMPORTANT: the following members are only valid in the instances corresponging to the first rep's.
  17.     int        m_cReps;                    
  18. };
  19.  
  20.  
  21. struct Face {
  22.     Face();
  23.    ~Face();
  24.  
  25.     int        m_cIndices;            // number of vertices in this face
  26.     int*    m_rgIndices;
  27.  
  28.     long    m_iGroup;            // material group
  29. };
  30.  
  31.  
  32.  
  33. struct Group {
  34.     char*    m_szMaterial;        // material name
  35.  
  36.     char*    m_szTextureFile;    // texture file name
  37.  
  38.     float    m_fDiffuseRed;        
  39.     float    m_fDiffuseGreen;    // diffuse components
  40.     float    m_fDiffuseBlue;        
  41.  
  42.     float    m_fSpecularRed;        
  43.     float    m_fSpecularGreen;    // specular components
  44.     float    m_fSpecularBlue;        
  45.  
  46.     float    m_fEmissiveRed;        
  47.     float    m_fEmissiveGreen;    // emissive components
  48.     float    m_fEmissiveBlue;        
  49.  
  50.     float    m_fShininess;        // specular power
  51.  
  52.     float    m_fTransparency;    // transparency
  53. };
  54.  
  55.  
  56. struct Bone {
  57.     Bone();
  58.    ~Bone();
  59.  
  60.     char*    m_szName;            // bone name
  61.  
  62.     int        m_cReps;            // number of rep's influenced
  63.  
  64.     int        m_cWeights;        // number of points influenced
  65.     float*    m_rgfWeights;
  66.     int*    m_rgiVertices;
  67.  
  68.     float    m_matOffset[4][4];    // inverse of bone's world coordinate transform at the time of binding
  69. };
  70.  
  71.  
  72. struct Mesh 
  73. {
  74.     Mesh();
  75.    ~Mesh();
  76.  
  77.     enum ShapeType
  78.     {
  79.         UNKNOWN,
  80.         POLY_MESH,
  81.         PATCH_MESH,
  82.         BONE
  83.     };
  84.  
  85.     ShapeType    m_kType;
  86.  
  87.     // control point info
  88.     
  89.     int            m_cReps;
  90.     Rep*        m_rgReps;
  91.     
  92.     int            m_cVertices;
  93.     DtVec3f*    m_rgVertices;        // lump of vertices
  94.  
  95.     int            m_cVertexColors;
  96.     DtRGBA*        m_rgVertexColors;    // lump of vertex colors
  97.  
  98.     int            m_cTexCoords;
  99.     DtVec2f*    m_rgTexCoords;        // lump of texture coords
  100.  
  101.     int            m_cNormals;
  102.     DtVec3f*    m_rgNormals;        // lump of normals
  103.  
  104.  
  105.     // face info
  106.  
  107.     int            m_cFaces;
  108.     Face*        m_rgFaces;
  109.  
  110.     int            m_cFaceIndices;    // total number of face indices (over all faces).
  111.  
  112.     // material info
  113.     
  114.     int            m_cGroups;
  115.     Group*        m_rgGroups;            // material groups
  116.  
  117.  
  118.     // skinning info
  119.  
  120.     int            m_cBones;
  121.     Bone*        m_rgBones;
  122.  
  123.     int            m_cMaxBonesPerVertex;
  124.     int            m_cMaxBonesPerFace;
  125. };
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.         
  134.  
  135.  
  136.  
  137. struct Key 
  138. {
  139.     int        m_iFrame;
  140.  
  141.     float    m_rgfTRS[4][4];            // TRS transform matrix        - NOT USED
  142.  
  143.     float    m_rgfQuaternion[4];        // quaternion rotation
  144.     float    m_rgfRotation[3];        // euler angles                - NOT USED
  145.     float    m_rgfScale[3];            // scale
  146.     float    m_rgfPosition[3];        // translation
  147. };
  148.  
  149.  
  150. struct Anim 
  151. {
  152.     char*    m_szName;
  153.  
  154.     int        m_cKeys;
  155.     Key*    m_rgKeys;
  156. };
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. int    MyDtShapeGetParentID
  205.     (
  206.         int    iShape
  207.     );
  208.  
  209.  
  210. int MyDtShapeGetChildren
  211.     (
  212.         int     iShape, 
  213.         int*    cChildren, 
  214.         int**   rgiChildren
  215.     );
  216.  
  217. int    MyDtShapeGetVertices
  218.     (
  219.         int            iShape,
  220.         int*        pcVertices, 
  221.         DtVec3f**    prgVertices
  222.     );
  223.  
  224.  
  225. int    MyDtShapeGetVertices
  226.     (
  227.         MObject&    objInput, 
  228.         MObject&    objOutput, 
  229.         int*        pcVertices, 
  230.         DtVec3f**    prgVertices
  231.     );
  232.  
  233. int    MyDtShapeGetControlPoints
  234.     (
  235.         MObject&    objInput, 
  236.         MObject&    objOutput, 
  237.         int*        pcVertices, 
  238.         DtVec3f**    prgVertices
  239.     );
  240.  
  241. int    MyDtShapeGetNormals
  242.     (
  243.         int            iShape,
  244.         int*        pcNormals, 
  245.         DtVec3f**    prgNormals
  246.     );
  247.  
  248.  
  249. int    MyDtShapeGetNormals
  250.     (
  251.         MObject&    objInput, 
  252.         MObject&    objOutput, 
  253.         int*        pcNormals, 
  254.         DtVec3f**    prgNormals
  255.     );
  256.  
  257. int    MyDtShapeGetTextureVertices
  258.     (
  259.         int            iShape,
  260.         int*        pcTexCoords, 
  261.         DtVec2f**    prgTexCoords
  262.     );
  263.  
  264. int    MyDtShapeGetVerticesColor
  265.     (
  266.         int            iShape,
  267.         int*        pcColors, 
  268.         DtRGBA**    prgColors
  269.     );
  270.  
  271. int    MyDtTextureGetFileName
  272.     (
  273.         char*    szMaterial, 
  274.         char**    pszTextureFile
  275.     );
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282. bool    MyDtShapeIsJoint
  283.         (
  284.             int    iShape
  285.         );
  286.  
  287.  
  288. bool    MyDtShapeIsPatchMesh
  289.         (
  290.             int    iShape
  291.         );
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308. #include <iostream.h>
  309.  
  310. class StringTable {
  311.     public:
  312.         StringTable() {};
  313.        ~StringTable() {};
  314.  
  315.         void reset();
  316.         void clear();
  317.         void add(char*);
  318.  
  319.     private:
  320.         char**    m_rgszStrings;
  321.         int        m_cStrings;
  322.         int        m_cStringsMax;
  323. };
  324.  
  325. inline void StringTable::reset() {
  326.     m_cStrings        = 0;
  327.     m_cStringsMax    = 64;
  328.     m_rgszStrings    = new char*[m_cStringsMax];
  329. }
  330.  
  331. inline void StringTable::clear() {
  332.     for (int iString = 0; iString < m_cStrings; iString++)
  333.         delete[] m_rgszStrings[iString];
  334.  
  335.     delete[] m_rgszStrings;
  336. }
  337.  
  338. inline void StringTable::add(char* szString) {
  339.     if (m_cStrings >= m_cStringsMax) {    // double the array size
  340.  
  341.         char**    rgszStrings    = m_rgszStrings;
  342.  
  343.         m_cStringsMax   += m_cStringsMax;
  344.  
  345.         m_rgszStrings    = new char*[m_cStringsMax];
  346.  
  347.         memcpy(m_rgszStrings, rgszStrings, m_cStrings * sizeof(char*));
  348.  
  349.         delete[] rgszStrings;
  350.     }
  351.  
  352.     m_rgszStrings[m_cStrings]    = szString;
  353.  
  354.     m_cStrings++;
  355. }
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. #endif